<?php

namespace app\user\controller;

use think\Controller;
use app\user\model\User as UserModel;
use think\facade\Session;

class User extends Controller
{
    //
    public function index($id){
        Session::set('userid',$id);
        $model = new UserModel;
        $user = $model->info($id);
        $friends = $model->showFriends($id);
        $this->assign([
            'user' => $user,
            'friends'=> $friends
        ]);
        return $this->fetch();
    }

    public function syllabus(){
        $model = new UserModel;
        $li = [];
        $data = $model->showClasses(Session::get('userid'));
        foreach ($data as $c) {
            $li[$c['date'] . '-' . $c['time']]=['classname'=>$c['classname'],'teacher'=>$c['teacher'],'classroom'=>$c['classroom']];
        }
        $this->assign('lessons',$li);
        return $this->fetch();
    }
}
